package cn.hd01.service;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import cn.hd01.export.result.ImportResult;
import cn.hd01.repository.entity.COrder;
import cn.hd01.repository.entity.COrderPayment;
import cn.hd01.repository.entity.DistributorLevel;

public interface COrderService extends BaseService<COrder, Integer> {
	Page<Object[]> findKValueList(COrder order, Pageable pageable); 
	
	COrder fillCOrder(COrder order, ImportResult result, List<DistributorLevel> levelList);
	
	/**
	 * 结算整个订单, deprecated的原因是因为业务要通过收款金额进行结算
	 * @param id
	 */
	@Deprecated
	void balanceOrder(Integer id);
	
	COrder findByFinanceOrderNo(String financeOrderNo);
	
	/**
	 * 
	 * @param id
	 * @param amount
	 */
	void balanceOrder(Integer id, COrderPayment payment);
	
	List<COrder> findAll(COrder order);
	
	Page<COrder> findAll(COrder order, Pageable pageable);
	
	List<Object[]> findSummary(String beginDate, String endDate);
	
	Integer countByIsBalanceAndDistributorId(String isBalance, Integer distributorId);
	
	Integer countByServantIdAndIsBalance(Integer ServantId, String isBalance);
	
	Integer countByIsBalance(String isBalance);
	
	Integer countOperationByToday();
	
	Integer countOperationByMonth();
	
	Double sumAchievementToday();
	
	Double sumAchievementMonth();
	
	Double progressMonthlyTarget();
	
	Double sumDistributorRebateRate(String isBalance);
	
	Integer findBalanceKValue(Integer distributorId);
	
	Integer findUnBalanceKValue(Integer distributorId);
	
	List<Object[]> findKValueGroupByDate(Integer distributorId);
	
	BigDecimal findCustomerSumAmount(Integer customerId);
	
	BigDecimal findKValue(Integer distributorId, String beginTime, String endTime, String day, String isBalance);
	
	List<Object[]> findRecommKvalue(Integer distributorId);
}